import QtQuick 2.0


Item {
    anchors.top: parent.top
    anchors.left: parent.left
    Row {
        anchors.top: parent.top
        anchors.topMargin: 15
        anchors.left: parent.left
        anchors.leftMargin: 15
        Grid {
            width: socialContent.width - 700 
            height: socialContent.height - 30
            columns: 3
            rows: 2
            spacing: 15
            Twitter{
                id: myTweet1
                speechText: ""
                language: "en"

                onTextChanged: {
                    settings.setValue("social/" + userSelection.loggedUser + "/tweet1", speechText);
                }
            }
            Twitter{
                id: myTweet2
                speechText: ""
                language: "en"

                onTextChanged: {
                    settings.setValue("social/" + userSelection.loggedUser + "/tweet2", speechText);
                }
            }
            Twitter{
                id: myTweet3
                speechText: ""
                language: "en"

                onTextChanged: {
                    settings.setValue("social/" + userSelection.loggedUser + "/tweet3", speechText);
                }
            }
            Twitter{
                id: myTweet4
                speechText: ""
                language: "en"

                onTextChanged: {
                    settings.setValue("social/" + userSelection.loggedUser + "/tweet4", speechText);
                }
            }
            Twitter{
                id: myTweet5
                speechText: ""
                language: "en"

                onTextChanged: {
                    settings.setValue("social/" + userSelection.loggedUser + "/tweet5", speechText);
                }
            }
            Twitter{
                id: myTweet6
                speechText: ""
                language: "en"

                onTextChanged: {
                    settings.setValue("social/" + userSelection.loggedUser + "/tweet6", speechText);
                }
            }
        }
        Column {
            spacing: 15
            Flickr {
                id: myFlickr1
                speechText: ""

                onTextChanged: {
                    settings.setValue("social/" + userSelection.loggedUser + "/flickr1", speechText);
                }
            }
            Flickr {
                id: myFlickr2
                speechText: ""

                onTextChanged: {
                    settings.setValue("social/" + userSelection.loggedUser + "/flickr2", speechText);
                }
            }
        }
    }
    
    Timer {
        interval: 10000 // 10 seconds
        running: true
        repeat: true
        triggeredOnStart: true
        onTriggered: {
            if(myTweet1.speechText != "") myTweet1.getNewTweet();
            if(myTweet2.speechText != "") myTweet2.getNewTweet();
            if(myTweet3.speechText != "") myTweet3.getNewTweet();
            if(myTweet4.speechText != "") myTweet4.getNewTweet();
            if(myTweet5.speechText != "") myTweet5.getNewTweet();
            if(myTweet6.speechText != "") myTweet6.getNewTweet();
        }
    }
    Timer {
        interval: 600000 // 600 seconds
        running: true
        repeat: true
        triggeredOnStart: true
        onTriggered: {
            if(myFlickr1.speechText != "") myFlickr1.getNewImages();
            if(myFlickr2.speechText != "") myFlickr2.getNewImages();
        }
    }

    onVisibleChanged: {
        myTweet1.speechText = settings.getValue("social/" + userSelection.loggedUser + "/tweet1");
        myTweet2.speechText = settings.getValue("social/" + userSelection.loggedUser + "/tweet2");
        myTweet3.speechText = settings.getValue("social/" + userSelection.loggedUser + "/tweet3");
        myTweet4.speechText = settings.getValue("social/" + userSelection.loggedUser + "/tweet4");
        myTweet5.speechText = settings.getValue("social/" + userSelection.loggedUser + "/tweet5");
        myTweet6.speechText = settings.getValue("social/" + userSelection.loggedUser + "/tweet6");

        myFlickr1.speechText = settings.getValue("social/" + userSelection.loggedUser + "/flickr1");
        myFlickr2.speechText = settings.getValue("social/" + userSelection.loggedUser + "/flickr2");
    }
}
